﻿// Decompiled with JetBrains decompiler
// Type: SP1.StructuralElement
// Assembly: SP1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 4A78F1E7-7FD5-407C-8917-5F99ECC43C34
// Assembly location: C:\Users\KasimGulcan\Desktop\Project\DynaCAD\bin\Debug\SP1.dll

using System.Windows;
using System.Windows.Controls;
using System.Xml;

namespace SP1
{
  public static class StructuralElement
  {
    public static Canvas CanvasCreator(XmlNode xn)
    {
      string str = "";
      Canvas canvas = new Canvas();
      foreach (XmlAttribute xmlAttribute in (XmlNamedNodeMap) xn.Attributes)
      {
        if (xmlAttribute.Value.Replace(" ", "") != "none")
        {
          switch (xmlAttribute.Name)
          {
            case "id":
              DefinitionElement.UIL.Add(new DefinitionElement.UIElements()
              {
                UI = (UIElement) canvas,
                Name = xmlAttribute.Value
              });
              continue;
            case "x":
              Canvas.SetLeft((UIElement) canvas, AtributeValueLibrary.DoubleConvertor(xmlAttribute.Value));
              continue;
            case "y":
              Canvas.SetTop((UIElement) canvas, AtributeValueLibrary.DoubleConvertor(xmlAttribute.Value));
              continue;
            case "height":
              canvas.Height = AtributeValueLibrary.DoubleConvertor(xmlAttribute.Value);
              continue;
            case "width":
              canvas.Width = AtributeValueLibrary.DoubleConvertor(xmlAttribute.Value);
              continue;
            case "transform":
              canvas = (Canvas) TransFormLibrary.TransForm((UIElement) canvas, xmlAttribute.Value);
              continue;
            case "stroke":
              str = str + "stroke:" + xmlAttribute.Value + ";";
              continue;
            case "fill":
              str = str + "fill:" + xmlAttribute.Value + ";";
              continue;
            case "stroke-miterlimit":
              str = str + "stroke-miterlimit:" + xmlAttribute.Value + ";";
              continue;
            case "stroke-dasharray":
              str = str + "stroke-dasharray:" + xmlAttribute.Value + ";";
              continue;
            case "stroke-width":
              str = str + "stroke-width:" + xmlAttribute.Value + ";";
              continue;
            case "stroke-opacity":
              str = str + "stroke-opacity:" + xmlAttribute.Value + ";";
              continue;
            case "fill-opacity":
              str = str + "fill-opacity:" + xmlAttribute.Value + ";";
              continue;
            case "opacity":
              str = str + "opacity:" + xmlAttribute.Value + ";";
              continue;
            case "stroke-linejoin":
              str = str + "stroke-linejoin:" + xmlAttribute.Value + ";";
              continue;
            case "fill-rule":
              str = str + "fill-rule:" + xmlAttribute.Value + ";";
              continue;
            case "viewBox":
              string[] strArray = xmlAttribute.Value.Split(' ');
              if (strArray.Length == 4)
              {
                double num1 = AtributeValueLibrary.DoubleConvertor(strArray[0]);
                double num2 = AtributeValueLibrary.DoubleConvertor(strArray[1]);
                double num3 = AtributeValueLibrary.DoubleConvertor(strArray[2]);
                double num4 = AtributeValueLibrary.DoubleConvertor(strArray[3]);
                canvas.Height = num4 - num2;
                canvas.Width = num3 - num1;
                continue;
              }
              continue;
            case "style":
              if (xn.Name == "g")
              {
                DefinitionElement.style = xmlAttribute.Value;
                continue;
              }
              continue;
            default:
              continue;
          }
        }
      }
      if (xn.Name == "g" & str != "")
        DefinitionElement.style = str;
      if (xn.HasChildNodes)
      {
        foreach (XmlNode xn1 in xn.ChildNodes)
        {
          if (xn1.Name == "defs")
          {
            DefinitionElement.Definition(xn1);
          }
          else
          {
            for (int index = 0; index < ElementDelegates.Element.Length; ++index)
            {
              if (xn1.Name == ElementDelegates.Element[index].Element)
                canvas.Children.Add(ElementDelegates.Element[index].Temsilci(xn1));
            }
          }
        }
        DefinitionElement.style = "stroke: #000000; fill: #000000";
      }
      return canvas;
    }
  }
}
